package bancosys.tec.utils.db.descriptor;

import java.util.List;

/**
 * VO para representar um descritor de base de referência.
 * 
 * @author jrenaut
 */
public class ReferenceDatabaseDescription {

    private List<ReferenceDatabaseDescription> dependencies;

    private List<ReferenceDatabaseEntry> schemaEntries;

    private List<ReferenceDatabaseEntry> postEntries;

    private List<ReferenceDatabaseEntry> referenceEntries;

    private String identifier;

    /**
     * C'tor
     * 
     * @param identifier Um identificador (único para bom funcionamento)
     * @param dependencies As dependências
     * @param schemaEntries As entradas de schema
     * @param postEntries List As entradas de postscript
     * @param referenceEntries List As entradas de base de referência
     */
    public ReferenceDatabaseDescription(String identifier, List<ReferenceDatabaseDescription> dependencies,
            List<ReferenceDatabaseEntry> schemaEntries, List<ReferenceDatabaseEntry> postEntries,
            List<ReferenceDatabaseEntry> referenceEntries) {
        this.identifier = identifier;
        this.dependencies = dependencies;
        this.schemaEntries = schemaEntries;
        this.postEntries = postEntries;
        this.referenceEntries = referenceEntries;
    }

    /**
     * @return the schemaEntries
     */
    public List<ReferenceDatabaseEntry> getSchemaEntries() {
        return this.schemaEntries;
    }

    /**
     * @return the postEntries
     */
    public List<ReferenceDatabaseEntry> getPostEntries() {
        return this.postEntries;
    }

    /**
     * @return the referenceEntries
     */
    public List<ReferenceDatabaseEntry> getReferenceEntries() {
        return this.referenceEntries;
    }

    /**
     * @return the dependencies
     */
    public List<ReferenceDatabaseDescription> getDependencies() {
        return this.dependencies;
    }

    /**
     * @return the identifier
     */
    public String getIdentifier() {
        return this.identifier;
    }

    /**
     * Devolve um hashcode baseado no identifier desta descrição.
     * 
     * @return int
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.identifier == null) ? 0 : this.identifier.hashCode());
        return result;
    }

    /**
     * Compara baseado no identifier desta descrição.
     * 
     * @param obj Object
     * @return boolean
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        ReferenceDatabaseDescription other = (ReferenceDatabaseDescription) obj;
        if (this.identifier == null) {
            if (other.identifier != null) {
                return false;
            }
        } else if (!this.identifier.equals(other.identifier)) {
            return false;
        }
        return true;
    }

    /**
     * @return string
     */
    @Override
    public String toString() {
        return String.format("[%s]", this.identifier);
    }

}
